public class 记录请求耗时日志{
    public static void main(String[] args) {

        for (int i = 1; i <= 3; i++) {
            final String requestId = "REQ-" + i;

            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    // 1. 模拟请求开始：记录信息
                    RequestContext.setRequestInfo(requestId);
                    System.out.println("开始处理 " + requestId);

                    // 2. 调用业务逻辑（中间不传任何参数）
                    BusinessService service = new BusinessService();
                    service.process();

                    // 3. 模拟请求结束：打印耗时
                    long time = RequestContext.getElapsedTime();
                    System.out.println("✅ " + RequestContext.getRequestId() 
                        + " 处理完成，耗时: " + time + "ms");

                    // 4. 清理当前线程数据
                    RequestContext.clear();
                }
            });

            t.start();
        }
    }
}